<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>  日期 </title>
</head>
<body>
    
</body>

<script>
    let now = new Date();
    console.log(now);
    function perty(num){
       return num = num > 9 ? num : '0' +num;
    }

    let year = now.getFullYear();
    let month = now.getMonth() +1;
    month = perty(month);
    let  day = now.getDate();
    day = perty(day);
    let hour = now.getHours();
    hour = perty(hour);
    let minute = now.getMinutes();
    minute = perty(minute);
    let second = now.getSeconds();
    second = perty(second);

    let str = year + '-'
            + month + '-'
            + day +'  '
            + hour + ':'
            + minute +':'
            + second;
     console.log(str);
            
    






</script>
</html>